var initalState = {
    name: '',
    pathname:'/index/swiper',
    key:'1',
    keypath:[],
    userinfo:[]

}

export default function reducer(state = initalState, action = { type: '', payload: null }) {
    // 深拷贝
    state = JSON.parse(JSON.stringify(state))
    // 判断action的类型
    if (action.type == 'INFO') {
        state.name = action.payload;
    }else if(action.type == "PATH") {
        state.pathname = action.payload
    }else if(action.type == 'KEY') {
        state.key = action.payload
    }else if(action.type == 'SAVE_KEYPATH'){
        state.keypath = action.payload
    }else if(action.type == 'USER'){
        state.userinfo = action.payload
    }

    // 必须返回一个state
    return state;
}